package com.csun.cmny.provider.controller.message.dailyEvaluate;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.provider.controller.message.AbstractCurTaskQueryProcessor;
import com.csun.cmny.provider.dto.OrderQueryDto;
import com.csun.cmny.provider.model.constant.OldInConstant;
import com.csun.cmny.provider.model.vo.RpcRoleVo;
import com.csun.cmny.provider.model.vo.message.OldmanInVo;
import com.csun.cmny.provider.service.CacRpcService;
import com.csun.cmny.provider.service.OldmanService;
import com.csun.cmny.provider.service.UacRpcService;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Component
public class DailyEvaluateTaskQuery extends AbstractCurTaskQueryProcessor<OldmanInVo> {

    @Resource
    private UacRpcService uacRpcService;
    @Resource
    private CacRpcService cacRpcService;
    @Resource
    private OldmanService oldmanService;

    @Override
    protected List<OldmanInVo> queryCurTaskList(LoginAuthDto loginAuthDto) {

//        List<OldmanInVo> voList = Lists.newArrayList();

        // 获取当前用户角色
        List<RpcRoleVo> roleVoList = uacRpcService.queryRoleListByUserId(loginAuthDto.getUserId());
        for(RpcRoleVo vo : roleVoList){
            if(vo.getRoleCode().equals(OldInConstant.IN_VAR_EVALUATE)){
                List<Integer> oldmanIdList = cacRpcService.queryNeedDailyEvaluateOldmanIdList(loginAuthDto.getGroupId());
                List<OldmanInVo> voList = Lists.newArrayList();
                if(oldmanIdList != null && oldmanIdList.size() > 0){
                    voList =  oldmanService.queryNeedDailyEvaluateOldmanList(oldmanIdList);
                }
                return voList;
            }
        }
        return null;
    }

    @Override
    protected List<OldmanInVo> queryCurOrderList(OrderQueryDto orderQueryDto, LoginAuthDto loginAuthDto) {
        return null;
    }
}
